<template>
	<view>
		<h2>回答问题</h2>
		<textarea v-model="answerData.content" style="margin-top: 10px;"></textarea>
		<button type="primary" style="margin-top: 10rpx;" @click="handleAnswerAdd">回答</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				answerData: {
					content: null,
					questionId: null,
				}
			}
		},
		methods: {
			handleAnswerAdd() {
				let data_ = {...this.answerData};
				data_['content'] = `<p>${this.answerData.content}</p>`
				this.$api.answernAdd(data_).then(res => {
					uni.redirectTo({
						url: '../questionDetail/questionDetail?questionId=' + this.answerData.questionId,
					})
				})
			}
		},
		onLoad(option) {
			this.answerData.questionId = option.questionId;
		}
	}
</script>

<style scoped>
	textarea {
		border: 2px solid #9BDBDB;
		width:100%;
		height: 800rpx;
	}
</style>
